﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace Yuchen.SOA.Utils
{
    public static class Extensions
    {
        /// <summary>
        /// 从http请求头中获取值
        /// </summary>
        /// <param name="headers"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetValue(this HttpRequestHeaders headers, string key)
        {
            IEnumerable<string> values;
            if(!headers.TryGetValues(key, out values))
            {
                return null;
            }
            return values.FirstOrDefault();
        }
    }
}
